'use strict';
// npx sequelize migration:generate --name=<操作名称></操作名称>
// npx sequelize db:migrate
// npx sequelize db:migrate:undo

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, DATE, STRING, BOOLEAN, DECIMAL } = Sequelize;
    await queryInterface.createTable('stores', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      title: STRING(255),
      code: { type: STRING(30), unique: true },
      floor: INTEGER,
      description: STRING(200),
      status: BOOLEAN,
      created_at: DATE,
      updated_at: DATE,
    });

    await queryInterface.createTable('places', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      code: { type: STRING(50), unique: true },
      description: STRING(200),
      store_id: INTEGER,
      store_floor: INTEGER,
      type: { type: INTEGER, comment: '库位性质 0：地面库位 1：货架库位' },
      shelf_code: { type: STRING(32), comment: '货架编码' },
      shelf_floor: { type: INTEGER, comment: '库位所在货架层数' },
      shelf_row: { type: INTEGER, comment: '库位所在货架列数' },
      bearing: { type: DECIMAL(19, 5), comment: '最大承重' },
      cbm: { type: DECIMAL(19, 5), comment: '存放体积' },
      area: { type: DECIMAL(19, 5), comment: '存放面积' },
      status: BOOLEAN,
      created_at: DATE,
      updated_at: DATE,
    });
  },

  down: async queryInterface => {
    await queryInterface.dropTable('stores');
    await queryInterface.dropTable('places');
  },
};
